from django.db import models
from django.contrib.auth.models import User
from eventapp.models import Asset, Event 

class EventVotes(models.Model):
    event = models.ForeignKey(Event)
    user = models.ForeignKey(User)
    positive = models.BooleanField() # Determines if vote is against (0) or not (1)
    
    def __unicode__(self):
        return "%s,%s" % (self.event, self.user)

    def __str__(self):
        return "%s,%s" % (self.event, self.user)
    
    class Meta:
        db_table = 'EventVotes'
        unique_together = ("event", "user")

class AssetVotes(models.Model):
    asset = models.ForeignKey(Asset)
    user = models.ForeignKey(User)
    positive = models.BooleanField() # Determines if vote is against (0) or not (1)
    
    def __unicode__(self):
        return "%s,%s" % (self.asset, self.user)

    def __str__(self):
        return "%s,%s" % (self.asset, self.user)
    
    class Meta:
        db_table = 'AssetVotes'
        unique_together = ("asset", "user")
